<?php
/*
Template Name: Page - Contact
*/
get_header();

?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); 

    $sidebar_position = get_post_meta($post->ID, 'sidebar_position', true);

    $content = get_the_content();
	$title = get_the_title();
	
	$content_class = ' class="position_left"';
	$sidebar_class = ' class="position_right"';
	
	if ( $sidebar_position == 'left' )
	{
		$content_class = ' class="position_right"';
		$sidebar_class = ' class="position_left"';
	}
	
	if ( $sidebar_position == 'website_selected' )
	{
		$website_selected_position = get_option('sidebar_position');
		
		if ( $website_selected_position == 'left' )
		{
			$content_class = ' class="position_right"';
			$sidebar_class = ' class="position_left"';
		}
	}
	
endwhile;
?>

	
    <section id="content_wrapper" class="clearfix">
    
        <?php
            if ( get_option('enable_google_maps') == 'yes' )
            {
                echo '<iframe width="960" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'; echo get_option('google_maps_url'); echo '&amp;output=embed" style="margin-top: 1px;"></iframe>';
            }
        ?>
    
        <div id="content_with_sidebar" <?php echo $content_class; ?>>
            
            <h1 class="page_title">
                <?php echo $title; ?>
            </h1>
            <div class="page_content">
                <?php the_content(); ?>
                
                <?php
                if ( get_option('use_recaptcha') == 'yes' )
                {
                    include('includes/recaptchalib.php'); 
                    
                    echo '<script type="text/javascript">';
                        echo 'var RecaptchaOptions = {';
                            echo 'theme : \'custom\',';
                            echo 'custom_theme_widget: \'recaptcha_widget\'';
                        echo '};';
                    echo '</script>';
                }
                 
                ?>
                 
               
                 <script type="text/javascript">
                
                    jQuery(document).ready(function() {
                        // validator
                        $("#contact_page_form").validate();
                        
                        // ajax stuff	
                        jQuery(".re_captcha_submit").click(function(){
                            jQuery('#contact_page_form .message_area').html('');
                        });
                        jQuery('#contact_page_form').ajaxForm({
                            target: '#contact_page_form .message_area'
                        });
                        jQuery('#contact_page_form .message_area').show('fast');
                        
                    });
                </script>
                
                <form id="contact_page_form" method="post" class="clearfix jqtransformdone" action="<?php echo get_template_directory_uri(); ?>/page_contact_sender.php">
                    
                    <?php 
                    
                    $destination_email = get_option('destination_email');
                    if ( $destination_email == '' )
                        $destination_email = get_bloginfo('admin_email');
                    else $destination_email = get_option('destination_email');

                    ?>
                    <input type="hidden" name="destination_email" value="<?php echo $destination_email; ?>" />
                    <?php 
                        if ( get_option('form_title') != '' )
                        {
                            echo '<h1>';
                                echo get_option('form_title');
                            echo '</h1>';
                        }
                    ?>
                    <div class="form_input form_left clearfix">                
                        <label for="name"><?php echo __('Name:', 'reFresh'); if (get_option('contact_name_required') == 'yes') echo ' *'; ?></label>
                        <br />
                        <input id="name" type="text" name="name" <?php if (get_option('contact_name_required') == 'yes') echo 'class="required"'; ?> />
                    </div>
                    <div class="form_input form_right clearfix">
                        <label for="email"><?php echo __('E-mail:', 'reFresh'); ?> *</label>
                        <br />
                        <input id="email" type="text" name="email" class="required email" />
                    </div>
                    <div class="form_input form_left clearfix">
                        <label for="company"><?php echo __('Company:', 'reFresh'); if (get_option('contact_company_required') == 'yes') echo ' *'; ?></label>
                        <br />
                        <input id="company" type="text" name="company" <?php if (get_option('contact_company_required') == 'yes') echo 'class="required"'; ?> />
                    </div>
                    <div class="form_input form_right clearfix">
                        <label for="phone"><?php echo __('Phone Number:', 'reFresh'); if (get_option('contact_phone_required') == 'yes') echo ' *'; ?></label>
                        <br />
                        <input id="phone" type="text" name="phone" <?php if (get_option('contact_phone_required') == 'yes') echo 'class="required"'; ?> />
                    </div>
                    <div class="form_element clearfix">
                        <label for="message"><?php echo __('Message:', 'reFresh'); ?> *</label>
                        <textarea id="message" rows="10" cols="60" spellcheck="false" name="message" class="required"></textarea>
                    </div>
                    
                    <?php
                    
                    if ( get_option('use_recaptcha') == 'yes' )
                    {
                        echo '<div id="recaptcha_widget" style="display:none">';
    
                            echo '<div id="recaptcha_left">';
                                echo '<span>';
									echo __( 'Read this:', 'reFresh' );
								echo '</span>';
                                echo '<div id="recaptcha_image"></div>';
                            echo '</div>';
                            
                                echo '<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>';
                            
                            echo '<div id="recaptcha_middle">';
                                echo '<div class="get_another_captcha"><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>';
                                echo '<div class="switch_to_audio recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">Get an audio CAPTCHA</a></div>';
                                echo '<div class="switch_to_video recaptcha_only_if_audio"><a href="javascript:switch_to_image()">Get an image CAPTCHA</a></div>';
                                echo '<div class="captcha_help"><a href="javascript:Recaptcha.showhelp()">Help</a></div>';
                            echo '</div>';
                            
                            echo '<div id="recaptcha_right">';
                                echo '<span class="recaptcha_only_if_image">';
									echo __( 'Enter the words here:', 'reFresh' );
								echo '</span>';
                                echo '<span class="recaptcha_only_if_audio">Enter the numbers you hear:</span>';
                                echo '<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />';
                            echo '</div>';
                    
                        echo '</div>';
                      
                        echo '<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k='; echo get_option('recaptcha_public_key'); echo '"></script>';
                        echo '<noscript>';
                            echo '<iframe src="http://www.google.com/recaptcha/api/noscript?k='; echo get_option('recaptcha_public_key'); echo'" height="300" width="500" frameborder="0"></iframe>';
                            echo '<br>';
                            echo '<textarea name="recaptcha_challenge_field" rows="3" cols="40">';
                            echo '</textarea>';
                            echo '<input type="hidden" name="recaptcha_response_field" value="manual_challenge">';
                        echo '</noscript>';
                        
                     } // END if ( get_option('use_recaptcha') == 1 )
                     ?>
                    
                    <div class="submit_area">
                        <input type="submit" class="re_captcha_submit" value="<?php echo __('Send Message','reFresh'); ?>">
                    </div>
                    <div class="message_area"></div>
                </form>
                
                
            </div><!-- .page_content -->
            
        </div> <!-- #content_with_sidebar -->
        
        <?php
        echo '<div id="sidebar"'.$sidebar_class.'>';
			echo '<div id="sidebar_content">';

				if ( is_active_sidebar( 'contact_widget_area' ) )
				{
					echo '<ul class="widget_content">';
					   dynamic_sidebar( 'contact_widget_area' );
					echo '</ul>';
				}
			
				get_sidebar();
			echo '</div>';
        echo '</div>';
        ?>
        
    </section> <!-- #content_wrapper -->
    
	<?php get_footer(); 

	return;

?>










